package com.rocksea.app.db;

import android.os.AsyncTask;
import com.rocksea.app.db.image.ImageTable;
import java.util.ArrayList;

/**
 * Created by 吴志华 on 2017/10/17.
 *
 */

public class AskQueryPileTask extends AsyncTask<Void,Void,ArrayList<ImageTable>>
{
    private String planNum;
    private String pileNo;
    private OnAskQueryCallBack onAskQueryCallBack;
    public AskQueryPileTask(String planNum, String pileNo,OnAskQueryCallBack onAskQueryCallBack)
    {
        this.planNum = planNum;
        this.pileNo = pileNo;
        this.onAskQueryCallBack = onAskQueryCallBack;
    }
    @Override
    protected void onPreExecute()
    {
        super.onPreExecute();
    }
    @Override
    protected void onCancelled()
    {
        super.onCancelled();
    }
    @Override
    protected ArrayList<ImageTable> doInBackground(Void... params)
    {
        return DbCenter.mImageDbHelper.query(planNum,pileNo);
    }
    @Override
    protected void onPostExecute(ArrayList<ImageTable> imageTables)
    {
        super.onPostExecute(imageTables);
        if (imageTables==null)
        {
            if (onAskQueryCallBack != null)
                onAskQueryCallBack.onError();
        }
        else
        {
            if (onAskQueryCallBack != null)
                onAskQueryCallBack.onSuccess(imageTables);
        }
    }
    public interface OnAskQueryCallBack
    {
        void onError();
        void onSuccess(ArrayList<ImageTable> imageTables);
    }
}
